#include <iostream>
#include <stdio.h>

using namespace std;

int pepl[50];
int main() {

    int n;
    cin >> n;
    int sum = 0;
    int num = 0;
    for(int i = 0; i < n; i++){
        cin >> pepl[i];
        sum += pepl[i];
    }
    int h,l;
    cin >> l >> h;
    
    if((sum < l*n)||(sum > h*n)){
        cout << -1;
        return 0;
    }
    while(1){
        int mi = 10000;
        int ma = -1;
        int miid = 0;
        int maid = 0;
        int flag = 0;
        for(int i = 0; i < n; i++){
            if(pepl[i] < mi){
                mi = pepl[i];
                miid = i;
            }
            if(pepl[i] > ma){
                ma = pepl[i];
                maid = i;
            }
            if((pepl[i] < l) || (pepl[i] > h)){
                flag = 1;
            }
        }
        if(!flag){
            cout << num;
            return 0;
        }
        pepl[miid] += 1;
        pepl[maid] -= 1;
        
        num += 1;
    }
}